package create;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.Method;

public class CreateDubboProviderMain2 {
	public static void main(String[] args) throws IOException, ClassNotFoundException {
		// File dir = new
		// File("/Users/jiangguoshun/Desktop/project/workspace-sts-3.6.4.RELEASE/osgit/jilefojing-net-project-soa/jilefojing-integration/src/main/java/com/jilefojing/service");
		File dir = new File("/Users/jiangguoshun/Desktop/project/workspace-sts-3.6.4.RELEASE/osgit/jilefojing-net-project-soa/jilefojing-integration/src/main/java/com/jilefojing/session/service");

		File[] ints = dir.listFiles();
		for (File _File : ints) {
			if (_File.isFile()) {
				String useName = _File.getName().substring(1).replace(".java", "");
				String fName = useName.substring(0, 1).toLowerCase() + useName.substring(1);

				String uName = "";
				String lName = fName.substring(0, 1);
				for (int i = 0; i < fName.length(); i++) {
					String word = fName.charAt(i) + "";
					if (word.matches("[A-Z]")) {
						uName += "_" + word.toLowerCase();
						lName += word.toLowerCase();
					} else {
						uName += word;
					}
				}
				// System.out.println(uName);
				// System.out.println(fName);
				// System.out.println(useName);

				Class ic = Class.forName("com.jilefojing.session.service.I" + useName);
				Method[] ms = ic.getMethods();

				String oms = "";

				for (Method m : ms) {
					String mn = m.getName();
					if (mn.startsWith("save") || mn.startsWith("add") || mn.startsWith("insert") || mn.startsWith("update") || mn.startsWith("edit") || mn.startsWith("register")
							|| mn.startsWith("delete") || mn.startsWith("clean") || mn.startsWith("cancle")) {
						oms += "		<dubbo:method name=\"" + mn + "\" retries=\"0\" />\n";
					}
				}

				String temp = "dubbo.provider.com.jilefojing.service.com.jilefojing.session.service.I" + useName + ".accesslog=${dubbo.provider.com.jilefojing.service.accesslog}\n"
						+ "dubbo.provider.com.jilefojing.service.com.jilefojing.session.service.I" + useName + ".version=${dubbo.provider.com.jilefojing.service.version}\n"
						+ "dubbo.provider.com.jilefojing.service.com.jilefojing.session.service.I" + useName + ".delay=${dubbo.provider.com.jilefojing.service.delay}\n"
						+ "dubbo.provider.com.jilefojing.service.com.jilefojing.session.service.I" + useName + ".timeout=${dubbo.provider.com.jilefojing.service.timeout}\n"
						+ "dubbo.provider.com.jilefojing.service.com.jilefojing.session.service.I" + useName + ".retries=${dubbo.provider.com.jilefojing.service.retries}\n"
						+ "dubbo.provider.com.jilefojing.service.com.jilefojing.session.service.I" + useName + ".connections=${dubbo.provider.com.jilefojing.service.connections}\n"
						+ "dubbo.provider.com.jilefojing.service.com.jilefojing.session.service.I" + useName + ".stub=${dubbo.provider.com.jilefojing.service.stub}\n"
						+ "dubbo.provider.com.jilefojing.service.com.jilefojing.session.service.I" + useName + ".mock=${dubbo.provider.com.jilefojing.service.mock}\n"
						+ "dubbo.provider.com.jilefojing.service.com.jilefojing.session.service.I" + useName + ".token=${dubbo.provider.com.jilefojing.service.token}\n"
						+ "dubbo.provider.com.jilefojing.service.com.jilefojing.session.service.I" + useName + ".async=${dubbo.provider.com.jilefojing.service.async}\n"
						+ "dubbo.provider.com.jilefojing.service.com.jilefojing.session.service.I" + useName + ".registry=${dubbo.provider.com.jilefojing.service.registry}\n"
						+ "dubbo.provider.com.jilefojing.service.com.jilefojing.session.service.I" + useName + ".register=${dubbo.provider.com.jilefojing.service.register}\n"
						+ "dubbo.provider.com.jilefojing.service.com.jilefojing.session.service.I" + useName + ".deprecated=${dubbo.provider.com.jilefojing.service.deprecated}\n"
						+ "dubbo.provider.com.jilefojing.service.com.jilefojing.session.service.I" + useName + ".dynamic=${dubbo.provider.com.jilefojing.service.dynamic}\n"
						+ "dubbo.provider.com.jilefojing.service.com.jilefojing.session.service.I" + useName + ".weight=${dubbo.provider.com.jilefojing.service.weight}\n"
						+ "dubbo.provider.com.jilefojing.service.com.jilefojing.session.service.I" + useName + ".owner=${dubbo.provider.com.jilefojing.service.owner}\n"
						+ "dubbo.provider.com.jilefojing.service.com.jilefojing.session.service.I" + useName + ".loadbalance=${dubbo.provider.com.jilefojing.service.loadbalance}\n"
						+ "dubbo.provider.com.jilefojing.service.com.jilefojing.session.service.I" + useName + ".cluster=${dubbo.provider.com.jilefojing.service.cluster}\n"
						+ "dubbo.provider.com.jilefojing.service.com.jilefojing.session.service.I" + useName + ".protocol=${dubbo.provider.com.jilefojing.service.protocol}\n"
						+ "dubbo.provider.com.jilefojing.service.com.jilefojing.session.service.I" + useName + ".layer=${dubbo.provider.com.jilefojing.service.layer}\n" + "\n" + "\n" + "\n" + "";

				System.out.println(temp);
			}
		}

	}
}
